package com.ram.controller;

import com.ram.pojo.AssetCategory;
import com.ram.pojo.Result;
import com.ram.service.AssetCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/asset/category")
public class AssetCategoryController {
    @Autowired
    private AssetCategoryService categoryService;

    @GetMapping("/list")
    public Result list() {
        return Result.success(categoryService.list());
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        return Result.success(categoryService.getById(id));
    }

    @PostMapping
    public Result add(@RequestBody AssetCategory category) {
        categoryService.add(category);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody AssetCategory category) {
        categoryService.update(category);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        categoryService.deleteById(id);
        return Result.success();
    }
} 